home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / oxcc1434.zip / DOC / OXCC.TXT < prev    next >
Text File  |  1996-09-03  |  18KB  |  448 lines

  1. OXCC.TXT Version: 1.433 -- preliminary 5 Nov 1995 by Norman D. Culver
  2.  
  3.     OXCC is a multipass interpreting C compiler with numerous language
  4.     extensions (see c.grm).
  5.  
  6.     OXCC generates output in an Architecture Neutral Format (ANF).
  7.     Sample backends are provided to guide the programmer in dealing with
  8.     ANF and in writing additional backends for a specific purpose.
  9.  
  10.     The builtin interpreter provides for a great deal of flexibility
  11.     but it does make the compiler a memory hog. The entire file under
  12.     compilation is stored in memory as an Abstract Syntax Tree (AST).
  13.     The AST can be printed to stdout with the -a option.
  14.  
  15.     Language extensions have been inspired by GCC, MSC, and Watcom C.
  16.     OXCC is designed to produce 16 bit, 32 bit, 64 bit, segmented and 
  17.     flat model code for any target architecture and operating system.
  18.  
  19.     OXCC can regenerate C source code after interpreting some or all of 
  20.     its' input. Source regeneration properly handles `malloced' data
  21.     containing pointers. The regenerated source code can be `shrouded'.
  22.     Regenerated source files have the suffix .cr .
  23.  
  24.     The builtin interpreter can be run in fast or slow mode. Slow mode
  25.     maintains elaborate pointer and initialization information which
  26.     often is the only way to catch a subtle runtime bug.
  27.  
  28.     The compiler and include files are located in the file `oxcc.cff'. It
  29.     is run from the command line by the skeleton program `oxcc.exe'
  30.     (see skel.doc). If no switches are enabled, OXCC merely checks the
  31.     input file(s) for errors.
  32.  
  33.     OXCC is reentrant; a set of C calls and a set of class based calls
  34.     are provided. Multiple instances of OXCC can be run simultaneously.
  35.     A program being compiled by OXCC can run OXCC as a subroutine.
  36.     The program under compilation can gain access to the AST and
  37.     symbol tables which describe it by using the calls __builtin_iv() and
  38.     __builtin_root(). See: toxcc.c
  39.  
  40. Usage: oxcc [-adoqrstuwABDEFGHILMOPRSTWY(] file...
  41.    -a == print ast                   -s == print symbol table
  42.    -t == print runtimes              -u == print memory usage
  43.    -r == run the code                -f == if run code, go fast
  44.    -L == produce listing             -E == preprocess only
  45.    -S == shrouded source output      -T == trace lines while interpreting
  46.    -P == Parse only
  47.    "-(args for interpreted main" 
  48.    -dn == enable debug output, 1=parser 2=lexer 3=both
  49.    -q == suppress printing gratuitous info
  50.    -o outfile == name of output file, default is first infile
  51.    -A == ansi_mode (suppress extensions, not fully implemented)
  52.    -W == if run code and not fast mode, warn about address problems
  53.    -w == suppress compiler warnings
  54.    -R func == if run code, start at function `func'
  55.    -Ipath == include path for the C preprocessor
  56.    -Ddef == define something for the C preprocssor
  57.    -Gx == generate output in format `x' (abdnmrs)
  58.    -Ox == generate output for operating system `x' (dDwWCNoOUL)
  59.    -Hx == generate output for hardware type `x' (iIPDHmM)
  60.    -Bx == generate output for debugger `x' (vwbgd)
  61.    -Fx == generate object file format `x' (oOPWBace)
  62.    -Yx == generate assembler format `x' (ugmt)
  63.    -Mx == use memory model `x' (tsmlchx)
  64.  
  65. OUTPUT OPTIONS
  66.     -Gs   regenerate source (output file has .cr suffix)
  67.     -SGs  regenerate shrouded source (output file has .cr suffix)
  68.     -Gb   generate bytecodes (calls oxccb, output file has .byt suffix)
  69.     -LGb  generate bytecode listing (calls oxccb, output file has .lst suffix)
  70.     -Ga   generate assembler output (calls oxccaH, where H is hardware type)
  71.     -Gd   generate readable ANF code (output file has .dbg suffix)
  72.     -Gm   generate machine code (calls oxccmH, where H is hardware type)
  73.     -Gn   generate ANF code (output file has .anf suffix)
  74.     -Gr   generate RIP code (calls oxccr, output file has .rip suffix)
  75.  
  76.     (see oxanf.doc, oxanf.h)
  77.     -Ox   placed in header slot `target_os'         default `D' DOS32PLAT
  78.     -Hx   placed in header slot `target_hardware'   default `I' INTEL8632
  79.     -Bx   placed in header slot `target_debugger'   default  0  NONE
  80.     -Fx   placed in header slot `obj_format'        default `a' AOUTFORMAT
  81.     -Yx   placed in header slot `target_assembler'  default `g' GAS
  82.     -Mx   placed in header slot `memory_model'      default `x' MODFLAT
  83.  
  84.  
  85. INCOMPATIBILITIES
  86.  
  87.     FUNCTION DECLARATIONS
  88.     OXCC, being a multipass compiler, always chooses the `best' declaration
  89.     for a function. The old style practice of hiding function declarations
  90.     with a declaration containing an unknown number of args (commonly used
  91.     by some programmers) just will not work. At the very least you
  92.     will get a warning if a subroutine is called with arguments imcommensurate
  93.     with the `best' declaration. OXCC will not assume that the declaration
  94.     of an undeclared function `func' is `int func()', you must explicitly
  95.     declare all functions.
  96.  
  97.  
  98. LANGUAGE EXTENSIONS
  99.  
  100.     RUNTIME INTERPRETATION
  101.     The -r switch will cause OXCC to interpret the AST if it can find
  102.     a function named `main' or failing that a function with the base name
  103.     of the input file e.g. test32.c with a function named `test32'.
  104.     The user can specify a unique starting function with the -R switch.
  105.     Arguments can be passed to the starting function by using the -( switch
  106.     providing the starting function adheres to the argc, argv convention.
  107.     e.g.:
  108.        oxcc -r test32.c "-(23 hello 14 -W"
  109.     Another way to cause runtime interpretation is to call the starting
  110.     function from the right hand side of the last initialized outer variable.
  111.     The only restriction is that the starting function must return a value.
  112.  
  113.  
  114.     INTERPRETING OUTER DECLARATIONS INCLUDING INNER STATIC VARIABLES
  115.     OXCC evaluates (interprets) non-constant expressions in outer declarations.
  116.     Anything that can appear in a normal C program can contribute to the value
  117.     that is stored in an initialized variable. Uninitialized variables can 
  118.     become initialized as a side effect of a function call. Two reserved words
  119.     `_ival' and `_ifunc' can be prepended to variables and functions 
  120.     respectively in order to prevent them from appearing in the output.
  121.     e.g.:
  122.         double q = sin(2.0) / cos(4.3);
  123.         void *ptr = malloc(200);    // interpreted malloc acts like calloc
  124.         static int x,y;
  125.         _ifunc int initfunc()      // function `initfunc' will not be output
  126.         {
  127.         int i;
  128.             x = 50;    // static variable x is initialized to 50.
  129.             y = 25;    // static variable y is initialized to 25.
  130.             for(i = 0; i < x; ++i)
  131.                 ptr[i] = malloc(y);    // initialize the array of pointers
  132.             return 0;
  133.         }
  134.         int startfunc(int z)  // function `startfunc' will appear in output
  135.         {
  136.             x += z;        // static variable x is modified before output
  137.             ...
  138.             return 0;
  139.         }
  140.         _ival int z = initfunc();    // variable `z' will not be output
  141.         char *ary[20] = {[2]=ptr[3], [3]=malloc(x), [18]=malloc(y)};
  142.         _ival int dummy = startfunc(25); // variable `dummy' will not be output
  143.  
  144.  
  145.     AUTOMATIC VARIABLES (INNER DECLARATIONS)
  146.     Automatic variables can be initialized with non-constant expressions.
  147.     Static variables mentioned inside functions can be non-constant and
  148.     will be initialized at outer declaration time.
  149.     `alloca' is not a suitable initializer for a static variable inside
  150.     a function, use `malloc'.
  151.  
  152.  
  153.     DEFAULT ARGUMENTS FOR FUNCTIONS
  154.     Functions can be declared with default args, just use an `=' and fill
  155.     in the right hand side.
  156.     e.g.:
  157.         int func(int a = 3, struct _a b = {2.3,4,1}, char *cp = "hello")
  158.         {
  159.             ....    
  160.         }
  161.     Functions with default args can be called with 0 or more actual args.
  162.     They can also be called normally.
  163.     e.g.:
  164.         func(cp: "goodby"); // a and b will take the default values
  165.         func(3,B,ptr);      // a, b, and cp are fully specified
  166.         func(3);            // b and cp will take the default values
  167.         func();             // a, b, and cp take the default values
  168.  
  169.  
  170.     LABELED IDENTIFIERS FOR INITIALIZING ARRAYS AND